<?php

namespace app\selladmin\model;

use think\Model;
use think\Db;

/*
 * 员工
 */

class Staff extends Model {
    //是否店铺创建者
    const STAFF_IS_CREATOR_0 = 0; //否
    const STAFF_IS_CREATOR_1 = 1; //是

    //员工是否在职
    const STAFF_ON_0 = 0; //否
    const STAFF_ON_1 = 1; //是

    //员工性别
    const STAFF_SEX_1 = 1; //男
    const STAFF_SEX_2 = 2; //女

    //查询员工信息
    public function StaffInfo($store_id, $telephone, $pagenum) {
        if ($telephone) {
            $staffwhere['telephone'] = $telephone;
        }
        if ($store_id) {
            $staffwhere['store_id'] = $store_id;
        }
        $staffwhere['staff_on'] = 1;
        $staffList = Db::name('staff')
                ->where($staffwhere)
                ->field("id,staff_name,telephone,staff_rank,login_time,add_time,staff_year,store_id")
                ->order("login_time desc")
                ->paginate($pagenum, false, ['var_page' => 'page2', 'fragment' => 'staff'])
                ->appends(['store_id' => $store_id, 'id' => $store_id, 'telephone' => $telephone]);
        return $staffList;
    }

}
